home *** CD-ROM | disk | FTP | other *** search
/ Holt Researcher: American History / Holt Researcher: American History.iso / pc / modules / global.cxt / 00118.txt < prev    next >
Encoding:
Text File  |  2000-01-28  |  1.3 KB  |  40 lines

  1. --
  2. -- launchApp takes a list of filepaths to documents and tries to find an application
  3. --   that will launch one of the documents.  As soon as it finds a good application,
  4. --   it tries to launch it, displaying an error message if anything goes wrong.
  5. --
  6. on launchApp me, browserDocList, description
  7.   -- if the application has already been launched then just bring the app to the front
  8.   if pInstanceID > 0 then
  9.     if pMAObj(mInstanceIsRunning, pInstanceID) then
  10.       set pInstanceID = pMAObj(mLaunch, pAppPath, EMPTY)
  11.       checkForError(me, pInstanceID)
  12.       return pInstanceID
  13.     end if
  14.   end if
  15.   
  16.   repeat with pBrowserDoc in browserDocList
  17.     set pAppPath = pMAObj(mLocateExecutable, pBrowserDoc)
  18.     if word 1 of pAppPath <> "Error:" then exit repeat
  19.   end repeat
  20.   
  21.   if word 1 of pAppPath = "Error:" then
  22.     alert "Sorry, I could not locate a " & description & "."
  23.   else
  24.     if not (the machineType=256) then
  25.       set result = pMAObj(mSetMenuBarHeight, 20)
  26.     end if
  27.     
  28.     set pInstanceID = pMAObj(mLaunch, pAppPath, pBrowserDoc)
  29.     
  30.     if not (the machineType=256) then
  31.       set result = pMAObj(mSetMenuBarHeight, 0)
  32.     end if
  33.     
  34.     checkForError(me, pInstanceID, description)
  35.   end if
  36.   
  37.   Return pInstanceID    -- contains an error code (< 0) if launching failed
  38. end
  39.  
  40.